--- HsPackage用来描述一个炉石拓展包。
---
--- 所谓拓展包，就是卡牌/游戏模式的一个集合而已。
local baseHsPackage = require "core.package"
--- 
local CardItem = require "packages.hearthstone.battlegrounds.core.card.carditem"
---
---@class HsPackage : Base.HsPackage
---@field public type HsPackageType @ 拓展包的类别，只会影响到选择拓展包的界面
---@field public extra_skills Skill[] @ 拓展包包含的额外技能，即不属于任何卡牌的技能
---@field public related_skills table<string, string> @ 对于额外技能而言的关联技能
---@field public cards CardItem[] @ 拓展包包含的卡牌
---@field public game_modes GameMode[] @ 拓展包包含的游戏模式
---@field public game_modes_whitelist? string[] @ 拓展包关于游戏模式的白名单
---@field public game_modes_blacklist? string[] @ 拓展包关于游戏模式的黑名单
---@field public skill_skels SkillSkeleton[]
---@field public card_skels CardSkeleton[]
---@field public card_specs [string, integer, integer, table][]
---@field public skin_specs table<string, string[]>

local HsPackage = baseHsPackage:subclass("Hearthstone.HsPackage")

---@alias HsPackageType integer

HsPackage.HearthstoneCardPack = 1 -- 炉石随从及法术包

--- 拓展包的构造函数。
---@param name string @ 包的名字
---@param _type? integer @ 包的类型，默认为武将包
function HsPackage:initialize(name, _type)
    baseHsPackage.initialize(self, name)
    assert(type(_type) == "nil" or type(_type) == "number")
    self.type = _type or HsPackage.HearthstoneCardPack
  
    self.extra_skills = {}
    self.related_skills = {}
    self.cards = {}
    self.game_modes = {}
    self.skill_skels = {}
    self.card_skels = {}
    self.card_specs = {}
end


--- 向拓展包中添加卡牌。
---@param card Card @ 要添加的卡牌
function HsPackage:addCard(card)
    assert(card.class and card:isInstanceOf(CardItem))
    card.package = self
    table.insert(self.cards, card)
  end
  
  --- 向拓展包中一次添加许多牌。
  ---@param cards CardItem[] @ 要添加的卡牌的数组
function HsPackage:addCards(cards)
    for _, card in ipairs(cards) do
      self:addCard(card)
    end
end

return HsPackage